#ifndef CfBm_____
#define CfBm_____

#include "Vector2f.h"
#include "Vector3f.h"
#include "PerlinNoise.h"

/*	Definition of Terms (cf. F. Kenton Musgrave)

	fBm: fractional Brownian motion. The particular kind of fractal used
	by Musgrave to produce terrains. It uses Perlin Noise to provide the 
	fractal's basis function. 

	Lacunarity: a counterpart to the fractal dimension that describes the 
	texture of a fractal. It has to do with the size distribution of the 
	holes. Roughly speaking, if a fractal has large gaps or holes (empty space), 
	it has high lacunarity; on the other hand, if a fractal is almost translationally 
	invariant, it has low lacunarity. Different fractals can be constructed 
	that have the same dimension but that look widely different because they 
	have different lacunarity. It can also be defined as the gap between successive
	frequencies in an fBm.

	Octaves: number of frequencies used in an fBm. It refers to that number of
	times the basis function is scaled down and added back to the original
	basis function.

	Basis Function: underlying shape that is repeated to create a fractal.
*/

//-----------------------------------------------------------------------------
class CfBm
//-----------------------------------------------------------------------------
{
  public:

	//-------------------------------------------------------------------------
	// members
	//-------------------------------------------------------------------------

	CPerlinNoise	m_PNoise;
	bool			m_bPrecomputefBmSpectralWeights;
	float			*m_pfExponentArrayfBm;

	//-------------------------------------------------------------------------
	// member functions
	//-------------------------------------------------------------------------

	float	fBm(vector3f vec3f, float H, float lacunarity, float octaves);
	float	fBmTurbulence(vector3f vec3f, float H, float lacunarity, float octaves); // same as fBm but uses abs(noise)
	float	MultiFractal(vector3f vec3f, float H, float lacunarity, float octaves, float offset);
	float	HeteroMultiFractal(vector3f vec3f, float H, float lacunarity, float octaves, float offset);
	float	HybridMultiFractal(vector3f vec3f, float H, float lacunarity, float octaves, float offset);
	float	RidgedMultiFractal(vector3f vec3f, float H, float lacunarity, float octaves, float offset, float gain);

	//-------------------------------------------------------------------------
	// constructors
	//-------------------------------------------------------------------------
	
	CfBm();

	//-------------------------------------------------------------------------
	// constructors
	//-------------------------------------------------------------------------

	~CfBm();

};

#endif
